<template>
    <view class="dynamicModel-list-v">
       
		<view class="list-warp">
			<mescroll-uni ref="mescrollRef"  @down="downCallback" @up="upCallback"  :down="downOption" :up="upOption">
				<view class="list">
					<view class="list-box" v-for="(item, index) in list" :key="item.prop">
						<view :index="index"  @open="open" :options="options" @click="goDetail(item.id,item.flowState)">
                        <view class="item">
                  
                        <view class="item-cell u-line-1" >
                            <text>职称：</text>
                            <text>{{item.F_CompanyTitle}}</text>
                        </view>
                        <view class="item-cell u-line-1" >
                            <text>建档时间：</text>
                            <text>{{item.F_Creatortime}}</text>
                        </view>
                        <view class="item-cell u-line-1" >
                            <text>姓名：</text>
                            <text>{{item.F_UserName}}</text>
                        </view>
                        <view class="item-cell u-line-1" >
                            <text>性别：</text>
                            <text>{{item.F_Gender | dynamicText(genderOptions)}}</text>
                        </view>
                        <view class="item-cell u-line-1" >
                            <text>身份证号：</text>
                            <text>{{item.F_CardId}}</text>
                        </view>
                      
                    
                        <view class="item-cell u-line-1" >
                            <text>籍贯：</text>
                            <text>{{item.F_NativePlace}}</text>
                        </view>
                        <view class="item-cell u-line-1" >
                            <text>家庭住址：</text>
                            <text>{{item.F_HomeAddress}}</text>
                        </view>
                        <view class="item-cell u-line-1" >
                            <text>入厂时间：</text>
                            <text>{{item.F_JoinTime}}</text>
                        </view>
                        <view class="item-cell u-line-1" >
                            <text>从事工种：</text>
                            <text>{{item.F_TypeWork}}</text>
                        </view>
                        </view>
						</view>
					</view>
				</view>
	
			</mescroll-uni>
		</view>
  
    </view>
</template>

<script>
    import resources from '@/libs/resources.js'
    import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
    import {
        getDictionaryDataSelector,
        getDataInterfaceRes
    } from '@/api/common'
    import request from '@/utils/request'
    export default {
		mixins: [MescrollMixin],
        data() {
            return {
                sortValue: '',
                searchForm: {
                    companyname:undefined,
                    companytitle:undefined,
                    creatortime:undefined,
                    username:undefined,
                    gender:undefined,
                    cardid:undefined,
                    education:undefined,
                    nativeplace:undefined,
                    homeaddress:undefined,
                    jointime:undefined,
                    typework:undefined,
                },
                downOption: {
                    use: true,
                    auto: false
                },
                upOption: {
                    page: {
                        num: 0,
                        size: 20,
                        time: null,
                    },
                    empty: {
                        use: true,
                        icon: resources.message.nodata,
                        tip: "暂无数据",
                        fixed: true,
                        top: "300rpx",
                        zIndex: 5,
                    },
                    textNoMore: '没有更多数据',
                    toTop: {
                        bottom: 250
                    }
                },
                genderOptions:[{"fullName":"男","id":"1"},{"fullName":"女","id":"2"}],
                genderProps:{"label":"fullName","value":"id"},
                educationOptions:[],
                educationProps:{"label":"fullName","value":"id"},
				list: [],
				listQuery: {
				    sort: 'desc',
				    sidx: '',
				    keyword: '',
				    json: ''
				},
				options: [
                    {
                        text: '删除',
                        style: {
                            backgroundColor: '#dd524d'
                        }
                    },
				],
				sortOptions:[
				    {
				        label: '公司名称降序',
				        sidx: 'companyname',
				        value: 'companynamedesc',
				        sort: 'desc'
				    },
				    {
				        label: '公司名称升序',
				        sidx: 'companyname',
				        value: 'companynameasc',
				        sort: 'asc'
				    },
				    {
				        label: '职称降序',
				        sidx: 'companytitle',
				        value: 'companytitledesc',
				        sort: 'desc'
				    },
				    {
				        label: '职称升序',
				        sidx: 'companytitle',
				        value: 'companytitleasc',
				        sort: 'asc'
				    },
				    {
				        label: '建档时间降序',
				        sidx: 'creatortime',
				        value: 'creatortimedesc',
				        sort: 'desc'
				    },
				    {
				        label: '建档时间升序',
				        sidx: 'creatortime',
				        value: 'creatortimeasc',
				        sort: 'asc'
				    },
				    {
				        label: '姓名降序',
				        sidx: 'username',
				        value: 'usernamedesc',
				        sort: 'desc'
				    },
				    {
				        label: '姓名升序',
				        sidx: 'username',
				        value: 'usernameasc',
				        sort: 'asc'
				    },
				    {
				        label: '性别降序',
				        sidx: 'gender',
				        value: 'genderdesc',
				        sort: 'desc'
				    },
				    {
				        label: '性别升序',
				        sidx: 'gender',
				        value: 'genderasc',
				        sort: 'asc'
				    },
				    {
				        label: '身份证号降序',
				        sidx: 'cardid',
				        value: 'cardiddesc',
				        sort: 'desc'
				    },
				    {
				        label: '身份证号升序',
				        sidx: 'cardid',
				        value: 'cardidasc',
				        sort: 'asc'
				    },
				    {
				        label: '学历降序',
				        sidx: 'education',
				        value: 'educationdesc',
				        sort: 'desc'
				    },
				    {
				        label: '学历升序',
				        sidx: 'education',
				        value: 'educationasc',
				        sort: 'asc'
				    },
				    {
				        label: '健康状况降序',
				        sidx: 'health',
				        value: 'healthdesc',
				        sort: 'desc'
				    },
				    {
				        label: '健康状况升序',
				        sidx: 'health',
				        value: 'healthasc',
				        sort: 'asc'
				    },
				    {
				        label: '籍贯降序',
				        sidx: 'nativeplace',
				        value: 'nativeplacedesc',
				        sort: 'desc'
				    },
				    {
				        label: '籍贯升序',
				        sidx: 'nativeplace',
				        value: 'nativeplaceasc',
				        sort: 'asc'
				    },
				    {
				        label: '家庭住址降序',
				        sidx: 'homeaddress',
				        value: 'homeaddressdesc',
				        sort: 'desc'
				    },
				    {
				        label: '家庭住址升序',
				        sidx: 'homeaddress',
				        value: 'homeaddressasc',
				        sort: 'asc'
				    },
				    {
				        label: '入厂时间降序',
				        sidx: 'jointime',
				        value: 'jointimedesc',
				        sort: 'desc'
				    },
				    {
				        label: '入厂时间升序',
				        sidx: 'jointime',
				        value: 'jointimeasc',
				        sort: 'asc'
				    },
				    {
				        label: '从事工种降序',
				        sidx: 'typework',
				        value: 'typeworkdesc',
				        sort: 'desc'
				    },
				    {
				        label: '从事工种升序',
				        sidx: 'typework',
				        value: 'typeworkasc',
				        sort: 'asc'
				    },
				],
                menuId:'',
            }
        },
        onLoad(e){
			this.menuId = e.menuId
            uni.$on('refresh', () => {
                this.list = [];
                this.mescroll.resetUpScroll();
            })
            this.dataAll()
        },
        onUnload() {
            uni.$off('refresh')
        },
        methods:{
			dataAll(){
				this.geteducationOptions()
			},
			geteducationOptions() {
			    getDictionaryDataSelector('6a6d6fb541b742fbae7e8888528baa16').then(res => {
			        this.educationOptions = res.data.list
			    })
			},
			closeData(e){
			    if(e==1){
			        // this.reset()
			    }
			},
            upCallback(page) {
    //             for(let i in this.searchForm){
				// 	if(!this.searchForm[i]){
				// 		delete this.searchForm[i]
				// 	}
				// }
                const query = {
                	accountId:JSON.parse(localStorage.getItem('userInfo')).data.userId
                }
                request({
                    url: '/api/system/DataInterface/357266082592981445/Actions/Response',
                    method: 'post',
                    data: query,
                }).then(res => {
					console.log(res.data.data);
					this.list=res.data.data
                }).catch(() => {
                  
                })
            },
           
            open(index) {
                this.list[index].show = true;
                this.list.map((val, idx) => {
                    if (index != idx) this.list[idx].show = false;
                })
            },
            search() {
                if (this.isPreview == '1') return
                this.searchTimer && clearTimeout(this.searchTimer)
                this.searchTimer = setTimeout(() => {
                    this.list = [];
        
                }, 300)
            },
            goDetail(id, status) {
                let btnType = ''
                let btnList = []
                btnList.push('btn_edit')
                btnList.push('btn_detail')
                if(btnList.includes('btn_detail')){
                    btnType = "btn_detail"
                }
                if(btnList.includes('btn_edit')){
                    btnType = "btn_detail"
                }
                if(!btnType) return
                this.jumPage(id, status,btnType)
            },
            addPage() {
				this.jumPage()
			},
            jumPage(id, status,btnType){
				// console.log(this.list[0].F_Id);
				id=this.list[0].F_Id
				if (!id && !status) btnType = 'btn_detail'
				uni.navigateTo({
                    url: id?'./form?menuId='+this.menuId+'&jurisdictionType='+btnType+'&id=' + id:'./form?menuId='+this.menuId+'&jurisdictionType='+btnType
                })
			},
            cellClick(item) {
                if (this.sortValue === item.value) return
                this.listQuery.sort = item.sort
                this.listQuery.sidx = item.sidx
                this.sortValue = item.value
                this.$refs.uDropdown.close();
                this.$nextTick(() => {
                    this.list = [];
       
                })
            },
            reset() {
                this.$refs.searchForm.resetFields()
            },
            closeDropdown() {
                this.$refs.uDropdown.close();
                this.$nextTick(() => {
                    this.list = [];
   
                })
            },
			dataList(data){
				let _list =[]
				for(let i=0;i<data.list.length;i++){
					let _data = data.list[i]
					_list.push(_data)
				}
				return _list;
			},
        },
    }
</script>

<style lang="scss">
    page {
        background-color: #f0f2f6;
        height: 100%;
        /* #ifdef MP-ALIPAY */
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        /* #endif */
    }
</style>
